package com.mgq.netty.chat.service.impl;

import com.mgq.netty.chat.service.UserService;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author MaGuangQi
 * @description
 * @date 2021-12-07 14:17
 **/
public class UserServiceImp implements UserService {
    private static ConcurrentHashMap<String, String> allUserMap = new ConcurrentHashMap<>();
    static {
        allUserMap.put("zhangsan", "123");
        allUserMap.put("lisi", "123");
        allUserMap.put("wangwu", "123");
        allUserMap.put("zhaoliu", "123");
    }
    @Override
    public boolean login(String username, String password) {
        if (username == null || "".equals(username)) {
            return false;
        }

        if (allUserMap.get(username) != null&&allUserMap.get(username).equals(password)) {
            return true;
        }
        return false;
    }
}
